package com.xj.utils;

import java.lang.reflect.Method;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

public class MyInvocationHandler implements InvocationHandler {
    private Object target;
    public MyInvocationHandler(Object target) {
        this.target = target;
    }
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("定时同步任务开始执行... " + Tools.getCurrentTime() );
        long startTime = System.currentTimeMillis();
        Object result = method.invoke(target, args);
        long endTime = System.currentTimeMillis();
        System.out.println("定时同步任务执行完毕... " + Tools.getCurrentTime() );
        Tools.calculateSyncExecutionTime(startTime, endTime);
        return result;
    }
}